import VueRouter from "vue-router";
import HomePage from "@/pages/HomePage.vue";
import Product from "@/pages/other/ProductFunction.vue";
import Mechanism from "@/pages/other/MechanismVersion.vue";
import ChannelCooperation from "@/pages/other/ChannelCooperation.vue";
import MembershipBenefits from "@/pages/other/MembershipBenefits.vue";
import HelpCenter from "@/pages/other/HelpCenter.vue";
import LoginPage from "@/pages/LoginPage.vue";
import BigPage from "@/pages/BigPage.vue";
import RegisterPage from "@/pages/RegisterPage.vue";
import MainPage from "@/pages/MainPage.vue";
import ClassDetail from "@/pages/ClassDetail.vue";
import CourseContent from "@/components/classDetail/CourseContent.vue";
import StudentAnalysis from "@/components/classDetail/StudentAnalysis.vue";
import GradeManage from "@/components/classDetail/GradeManage.vue";
import CourseIntroduce from "@/components/classDetail/CourseIntroduce.vue";
import SubmitWork from "@/pages/SubmitWork.vue";
import MemberManage from "@/pages/MemberManagePage.vue";
import CorrectWork from "@/pages/CorrectWork.vue";

export default new VueRouter({
    routes: [
        {
            path: '/',
            redirect: '/bigPage/homepage',
            meta: {isAuth: true, title: '主页'}
        },
        {
            name: 'bigPage',
            path: '/bigPage',
            component: BigPage,
            children: [
                {
                    path: 'homepage',
                    component: HomePage,
                },
                {
                    path: 'product',
                    component: Product
                },
                {
                    path: 'mechanism',
                    component: Mechanism
                },
                {
                    path: 'cooperation',
                    component: ChannelCooperation
                },
                {
                    path: 'membership',
                    component: MembershipBenefits
                },
                {
                    path: 'help',
                    component: HelpCenter
                },],
            meta: {isAuth: true, title: '首页'}

        },
        {
            name: 'loginPage',
            path: '/login',
            component: LoginPage,
        },
        {
            name: 'registerPage',
            path: '/register',
            component: RegisterPage
        },
        {
            name: 'mainPage',
            path: '/main',
            component: MainPage,
            meta:{ isAuth: true,title:'登录首页'}
        },
        {
            name: 'classDetail',
            path: '/classDetail',
            component: ClassDetail,
            children: [
                {path: 'courseContent', name: 'defaultView', component: CourseContent},
                {path: 'studentAnalysis', name: 'studentAnalysis', component: StudentAnalysis},
                {path: 'gradeManage', name: 'gradeManage', component: GradeManage},
                {path: 'courseIntroduce', name: 'courseIntroduce', component: CourseIntroduce}
            ],
            meta:{ isAuth: true,title:'班级首页'}
        },
        {
            name: 'submitWork',
            path: '/submitWork',
            component: SubmitWork,
            meta:{ isAuth: true,title:'提交作业首页'}
        },
        {
            name: 'correctWork',
            path: '/correctWork',
            component: CorrectWork,
            meta:{ isAuth: true,title:'批改作业首页'}
        },
        {
            name:'memberManage',
            path: '/memberManage',
            component:MemberManage,
            meta:{ isAuth: true,title:'成员管理'}
        }
    ]
})


const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
